#include <ros/ros.h>
#include <bits/stdc++.h>


int main (int argc, char** argv) 
{   
  ros::init(argc, argv, "read_csv");
  ros::NodeHandle nh("~");

  double max_replan_time = DBL_MIN;
  double min_replan_time = DBL_MAX;
  double avg_replan_time = 0.0;;

  std::ifstream _csvInput;
	_csvInput.open("/home/up/buaa_ws/plan_time.csv"); 
  std::string _Oneline;
  int count= 0;
	while(std::getline(_csvInput, _Oneline))
	{
		std::istringstream _Readstr(_Oneline);	

		std::string _partOfstr;
		// Eigen::Matrix<double ,7,1> single_fake_drone;
		for(int i = 0; i < 1; i++)
		{	
			getline(_Readstr, _partOfstr, ',');
			// single_fake_drone(i) = atof(_partOfstr.c_str());	
      double plan_time = atof(_partOfstr.c_str());
      max_replan_time = std::max(plan_time,max_replan_time);
      min_replan_time = std::min(plan_time,min_replan_time);
      avg_replan_time += plan_time;
		}
    count++;
	}

  std::cout<<"max plan time:"<<max_replan_time<<std::endl;
  std::cout<<"max plan time:"<<min_replan_time<<std::endl;
  std::cout<<"average plan time:"<<avg_replan_time/count<<std::endl;


  return 0;
}
